/**
 * 
 */
package com.lanswon.qzsmk.listener;

import java.util.LinkedHashMap;
import java.util.List;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import ch.qos.logback.classic.Logger;

import com.lanswon.qzsmk.dao.SysPermissionMapper;
import com.lanswon.qzsmk.model.SysPermission;

/**
 * 配置权限
 * @author sun
 *
 */
public class FilterChainDefinitionMapBuilder {
	
	@Autowired
	SysPermissionMapper spm;

	private static Logger logger = (Logger) LoggerFactory
			.getLogger(FilterChainDefinitionMapBuilder.class);

	
	
	  public LinkedHashMap<String,String> buildFilterChainDefinitionMap(){
		  logger.debug("***************************权限配置**************************");
		  LinkedHashMap<String,String> map= new LinkedHashMap<>();
		  
		  map.put("/index.html", "user");
		  map.put("/services/**", "anon");
		  
		  map.put("/chart/**", "anon");
		  map.put("/themes/**", "anon");
		  map.put("/js/**", "anon");
		  map.put("/themes/**", "anon");
		  map.put("/bin/**", "anon");
		  map.put("/bin/**", "anon");
		  map.put("/uploadify/**", "anon");
		  map.put("/getLoginException", "anon");
		  map.put("/validCode.jpeg", "anon");
		  map.put("/logout.html", "logout");
		  
		  map.put("/favicon.ico", "anon");
//		  map.put("/", "anon");
		 
		  List<SysPermission> list = spm.queryPermission();
		  for(SysPermission s:list){
			  map.put(s.getPrivilegeResource(), "perms["+s.getPercode()+"]");
			  logger.debug(s.getPrivilegeResource()+"----------"+"perms["+s.getPercode()+"]");
			  
		  }
		  

		  map.put("/**", "authc");
		  logger.debug("***************************权限配置***===============***********************{}",list.size());
		return map;  
		  
	  }
}
